﻿
using BCGM.MedicalWisdom.IServices;
using BCGM.MedicalWisdom.Model.Models;
using BCGM.MedicalWisdom.Services.BASE;
using BCGM.MedicalWisdom.Repository.BASE;
using System.Threading.Tasks;
using System.Collections.Generic;
using BCGM.MedicalWisdom.Model.ViewModels.Order;
using SqlSugar;

namespace BCGM.MedicalWisdom.Services
{
    public class AreaServices : BaseServices<Area>, IAreaServices
    {
        private readonly IBaseRepository<Area> _dal;
        public AreaServices(IBaseRepository<Area> dal)
        {
            this._dal = dal;
            base.BaseDal = dal;
        }

        public async Task<List<AreaOutputDto>> GetAreaSql()
        {
            string sql = "select * from Area where IsDeleted = 0;";
            SugarParameter[] parameters = null;
            var list = await base.BaseDal.QuerySql(sql, parameters);
            List<AreaOutputDto> areaOutputs = new List<AreaOutputDto>();
            foreach (var item in list)
            {
                areaOutputs.Add(new AreaOutputDto
                {
                    AreaId = item.AreaId,
                    AreaName = item.AreaName,
                    Createdby = item.Createdby,
                    CreateTime = item.CreateTime,
                    Updatedby = item.Updatedby,
                    UpdatedTime = item.UpdatedTime,
                    Deletedby = item.Deletedby,
                    DeletedTime = item.DeletedTime,
                    IsDeleted = item.IsDeleted,
                });
            }
            return areaOutputs;
        }
    }
}